package com.example.controller;

import com.example.entity.FacilityClassify;
import com.example.entity.Page.PageRequest;
import com.example.result.CommonResult;
import com.example.service.FacilityClassifyService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: tobed
 * @date: 2022/11/14
 * @time: 19:12
 */
@RestController
@RequestMapping("facilityClassify")
public class FacilityClassifyController {

    @Autowired
    FacilityClassifyService facilityClassifyService;

    /*修改*/
    @PostMapping("update/{id}/{facilityClassifyName}")
    public CommonResult update(@PathVariable Integer id,@PathVariable String facilityClassifyName){
        CommonResult commonResult = facilityClassifyService.update(id,facilityClassifyName);
        return commonResult;
    }

    /*设备分类全查*/
    @GetMapping("list")
    public CommonResult list(FacilityClassify facilityClassify, PageRequest pageRequest){
        CommonResult commonResult = facilityClassifyService.list(facilityClassify.getFacilityClassifyName(),pageRequest);
        return commonResult;
    }

    /*状态修改*/
    @PostMapping("updateStatus/{id}/{status}")
    public CommonResult updateStatus(@PathVariable Integer id,@PathVariable int status){
        CommonResult commonResult = facilityClassifyService.updateStatus(id,status);
        return commonResult;
    }

    /*删除分类*/
    @PostMapping("remove/{id}")
    public CommonResult remove(@PathVariable Integer id){
        CommonResult commonResult = facilityClassifyService.remove(id);
        return commonResult;
    }

    /*添加分类信息*/
    @PostMapping("create")
    public CommonResult create(@RequestBody FacilityClassify facilityClassify){
        CommonResult commonResult = facilityClassifyService.create(facilityClassify);
        return commonResult;
    }

}
